//
//  WKVideoModelFrame.m
//  WKDemo
//
//  Created by apple on 14-8-4.
//  Copyright (c) 2014年 com.app. All rights reserved.
//

#import "WKVideoModelFrame.h"
#import "WKVidelModel.h"

@implementation WKVideoModelFrame
-(void)setVideoModel:(WKVidelModel *)videoModel
{
    _videoModel = videoModel;
    
    CGFloat magrin = 10;
    // 1.头像
    CGFloat iconX = magrin;
    CGFloat iconY = magrin;
    CGFloat iconW = 35;
    CGFloat iconH = 35;
    self.iconFrame = CGRectMake(iconX, iconY, iconW, iconH);

    
    // 2.昵称
    CGFloat nameX = CGRectGetMaxX(self.iconFrame) + magrin;
    CGFloat nameY = iconY;
    CGSize nameSize = [videoModel.name sizeWithFont:[UIFont systemFontOfSize:11.0]];
    self.nameFrame = (CGRect){{nameX, nameY}, nameSize};
  
    
    CGFloat timeX = self.nameFrame.origin.x;
    CGFloat timeY = CGRectGetMaxY(self.nameFrame)+5;
    CGSize timesize = [videoModel.passtime sizeWithFont:[UIFont systemFontOfSize:11.0]];
    self.timeFrame = (CGRect){{timeX, timeY}, timesize};

    
    CGFloat textX = iconX;
    CGFloat textY = CGRectGetMaxY(self.iconFrame) + magrin;
    CGFloat maxW = [UIScreen mainScreen].bounds.size.width - 2 * textX;
    CGSize maxSize = CGSizeMake(maxW, MAXFLOAT);
    CGSize textSize = [videoModel.text sizeWithFont:[UIFont systemFontOfSize:14.0] constrainedToSize:maxSize];
    self.textFrame = (CGRect){{textX, textY}, textSize};

    
    CGFloat showViewX = magrin;
    CGFloat showViewY = CGRectGetMaxY(self.textFrame)+ magrin;
    CGFloat showViewW = [UIScreen mainScreen].bounds.size.width - magrin*2;
    CGFloat showViewH = 200;
    self.showViewFrame = CGRectMake(showViewX, showViewY, showViewW, showViewH);

    NSString *playStr = [NSString stringWithFormat:@"%@次播放",videoModel.playcount];
    CGSize playCountLabelSize = [playStr sizeWithFont:[UIFont systemFontOfSize:11.0]];
    CGFloat playCountLabelX = self.showViewFrame.size.width - playCountLabelSize.width + 10 ;
    self.playCountLabelFrame = (CGRect){{playCountLabelX, self.showViewFrame.origin.y }, playCountLabelSize};
 
    
    CGFloat buttonW = 43;
    CGFloat buttonH = buttonW;
    CGFloat buttonX = self.showViewFrame.size.width*0.5 - buttonW*0.5;
    CGFloat buttonY = self.showViewFrame.size.height*0.5 - buttonH*0.5;
    self.buttonFrame = CGRectMake(buttonX, buttonY, buttonW, buttonH);
    
    self.sliderFrame = CGRectMake(self.showViewFrame.origin.x, CGRectGetMaxY(self.showViewFrame)-1, self.showViewFrame.size.width, 1);
    

    CGSize playTimeLabelSize = [@"00:00" sizeWithFont:[UIFont systemFontOfSize:11.0]];
    CGFloat playTimeLabelX = self.showViewFrame.size.width - playTimeLabelSize.width + 10;
    self.playTimeLabelFrame = (CGRect){{playTimeLabelX, CGRectGetMaxY(self.showViewFrame)-playTimeLabelSize.height}, playTimeLabelSize};
    
    self.playViewFrame = CGRectMake(showViewX, showViewY, showViewW, showViewH);
    
    self.toolbarFrame = CGRectMake(self.showViewFrame.origin.x, CGRectGetMaxY(self.playViewFrame)+5, self.showViewFrame.size.width, 40);
    
    self.cellHeight = CGRectGetMaxY(self.toolbarFrame)+5;

}
@end
